Imports System.Security.Cryptography

Partial Class Client_ModifyPassword
    Inherits System.Web.UI.Page
    Dim _UserId As String
    Dim _bo As New Bo

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _UserId = Session("UserId")
        If _UserId = "" Then
            Response.Redirect("frmLogin.aspx")
        End If
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Dim md5Hasher As MD5 = MD5.Create()
        Dim data As Byte() = md5Hasher.ComputeHash(Encoding.[Default].GetBytes(txtPassword.Text))
        Dim sBuilder As New StringBuilder()
        For i As Integer = 0 To data.Length - 1
            sBuilder.Append(data(i).ToString("x2"))
        Next
        _bo.UpdatePassword(sBuilder.ToString, _UserId)
        MsgBox("Password Updated")
        Session("UserId") = _UserId
        Response.Redirect("frmDatalist.aspx")
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtPassword.Text = ""
        txtConfirmPassword.Text = ""
    End Sub
End Class
